package middleware

import (
	"context"
	"fmt"
	"gdmin/servlet"
	"github.com/cloudwego/hertz/pkg/app"
	"github.com/cloudwego/hertz/pkg/common/hlog"
)

func HandlerError(c context.Context, ctx *app.RequestContext, err interface{}, stack []byte) {
	if err == nil {

		return
	}

	hlog.Info(c, "异常文本 = ", err, " 异常堆栈 ", string(stack))

	servlet.FailWithDetailed(fmt.Sprintf("%v", err), fmt.Sprintf("%v", err), ctx)
	ctx.Abort()

}
